#include <bits/stdc++.h>
#define N 100002
using namespace std;
int que;
int n,m,L,V,ans1;
int d[N],v0[N],v1[N],a[N],p[N];
double s[N],t[N];
bool vis[N],flg;
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>que;
    while(que--){
        ans1=0;
        memset(p,0,sizeof(p));
        memset(vis,0,sizeof(vis));
        cin>>n>>m>>L>>V;
        flg=0;
        for(int i=1;i<=n;i++){
            cin>>d[i]>>v0[i]>>a[i];
            if(a[i]!=0)flg=1;
        }
        for(int i=1;i<=m;i++){
            cin>>p[i];
        }

        for(int i=1;i<=m;i++){
            for(int j=1;j<=n;j++){
                v1[j]=p[j]-d[j];
                t[j]=(v1[j]*1.0-v0[j]*1.0)/a[j]*1.0;
                s[j]=v0[j]*t[j]+0.5*a[j]*t[j]*t[j];
                if(v1[j]==s[j]){
                    if(sqrt(v0[j]*1.0*v0[j]*1.0+2.0*a[j]*s[j])>V&&vis[j]==0){
                        vis[j]=1;
                        ans1++;
                    }
                }else{
                    if(v1[j]>V&&vis[j]==0){
                        vis[j]=1;
                        ans1++;
                    }
                }
            }
        }
        cout<<ans1<<" ";
        if(flg==0){
            cout<<1;
            continue;
        }
        cout<<ans1;
    }
    return 0;
}
